package com.oscar.ehome.presenter;

import com.oscar.ehome.bean.loginbean.idcardbean.IdCardBean;
import com.oscar.ehome.model.HttpModel;
import com.oscar.ehome.model.HttpModelImple;
import com.oscar.ehome.model.OnHttpListener;
import com.oscar.ehome.view.loginview.view.ApporveView;

import java.io.File;

/**
 * Created by author 孟琬和
 * on 2017/6/25.
 * 认证身份证
 */

public class ApporvePresenter {

    ApporveView view;
    HttpModel httpModel;

    public ApporvePresenter(ApporveView view) {
        this.view = view;
        httpModel = new HttpModelImple();
    }

    /**
     * 上传到本地服务器
     *
     * @param token
     * @param file
     */
    public void approveidcard(String token, String imgname, File file) {
        httpModel.approve(token, imgname, file, new OnHttpListener<IdCardBean>() {

            @Override
            public void onSuccess(IdCardBean obj) {
                if (view != null)
                    view.approvecard(obj);
            }

            @Override
            public void onError(String msg) {
                if (view != null)
                    view.erry(msg);
            }

            @Override
            public void onFailure() {
                if (view != null)
                    view.erroy();
            }
        });
    }

}
